package com.daxia.bumall.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * Order
 */
@Entity
@Table(name = "`order`") 
public class Order extends BaseModel {
	/**
	 * id
	 */
	@Id
	@GeneratedValue
	@Column(name = "id")
    private Long id;
	/**
	 * 订单编号
	 */
	@Column(name = "orderNo")
    private String orderNo;
	/**
	 * 购买用户
	 */
	@ManyToOne
	@JoinColumn(name = "user_id")
    private User user;
	/**
	 * 运营商
	 */
	@ManyToOne
	@JoinColumn(name = "operator_user_id")
    private User operatorUser;
	/**
	 * 工厂
	 */
	@ManyToOne
	@JoinColumn(name = "factory_user_id")
    private User factoryUser;
	/**
	 * 下单时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")	
	@Column(name = "createTime")
    private Date createTime;
	/**
	 * 支付时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")	
	@Column(name = "payTime")
    private Date payTime;
	/**
	 * 发货时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")	
	@Column(name = "deliverTime")
    private Date deliverTime;
	/**
	 * 订单总额
	 */
	@Column(name = "amount")
    private BigDecimal amount;
	/**
	 * 实付金额
	 */
	@Column(name = "actualPayAmount")
    private BigDecimal actualPayAmount;
	/**
	 * 支付状态， 0未支付，1已支付
	 */
	@Column(name = "payStatus")
    private Integer payStatus;
	/**
	 * 状态， 0待确认，1待发货， 2待收货， 3已收货， 4已完成， 5已关闭
	 */
	@Column(name = "status")
    private Integer status;
	/**
	 * 支付方式
	 */
	@Column(name = "payType")
    private Integer payType;
	/**
	 * 收件人
	 */
	@Column(name = "receiveName")
    private String receiveName;
	/**
	 * 收件人电话
	 */
	@Column(name = "receiveMobile")
    private String receiveMobile;
	/**
	 * 邮编
	 */
	@Column(name = "zipcode")
    private String zipcode;
	/**
	 * 省
	 */
	@ManyToOne
	@JoinColumn(name = "province_id")
    private Province province;
	/**
	 * 市
	 */
	@ManyToOne
	@JoinColumn(name = "city_id")
    private City city;
	/**
	 * 地区
	 */
	@ManyToOne
	@JoinColumn(name = "district_id")
    private District district;
	/**
	 * 详细地址
	 */
	@Column(name = "address")
    private String address;
	/**
	 * 物流公司
	 */
	@Column(name = "expressCompany")
    private String expressCompany;
	/**
	 * 物流单号
	 */
	@Column(name = "expressNo")
    private String expressNo;
	/**
	 * 运营商备注
	 */
	@Column(name = "operatorRemark")
    private String operatorRemark;
	/**
	 * 工厂备注
	 */
	@Column(name = "factoryRemark")
    private String factoryRemark;
	/**
	 * 发票类型， 0不需要，1普通发票， 2增值税发票
	 */
	@Column(name = "invoiceType")
    private Integer invoiceType;
	/**
	 * 发票抬头
	 */
	@Column(name = "invoiceTitle")
    private String invoiceTitle;
	
	@OneToMany(mappedBy = "order")
	private List<OrderItem> orderItems;
	
	public Long getId() {
    	return id;
    }
	
    public void setId(Long id) {
    	this.id = id;
    }
	
	public String getOrderNo() {
    	return orderNo;
    }
	
    public void setOrderNo(String orderNo) {
    	this.orderNo = orderNo;
    }
	
	public User getUser() {
    	return user;
    }
	
    public void setUser(User user) {
    	this.user = user;
    }
	
	public User getOperatorUser() {
    	return operatorUser;
    }
	
    public void setOperatorUser(User operatorUser) {
    	this.operatorUser = operatorUser;
    }
	
	public User getFactoryUser() {
    	return factoryUser;
    }
	
    public void setFactoryUser(User factoryUser) {
    	this.factoryUser = factoryUser;
    }
	
	public Date getCreateTime() {
    	return createTime;
    }
	
    public void setCreateTime(Date createTime) {
    	this.createTime = createTime;
    }
	
	public Date getPayTime() {
    	return payTime;
    }
	
    public void setPayTime(Date payTime) {
    	this.payTime = payTime;
    }
	
	public Date getDeliverTime() {
    	return deliverTime;
    }
	
    public void setDeliverTime(Date deliverTime) {
    	this.deliverTime = deliverTime;
    }
	
	public BigDecimal getAmount() {
	    return moneyValue(amount);
    }
	
    public void setAmount(BigDecimal amount) {
    	this.amount = amount;
    }
	
	public BigDecimal getActualPayAmount() {
	    return moneyValue(actualPayAmount);
    }
	
    public void setActualPayAmount(BigDecimal actualPayAmount) {
    	this.actualPayAmount = actualPayAmount;
    }
	
	public Integer getPayStatus() {
    	return payStatus;
    }
	
    public void setPayStatus(Integer payStatus) {
    	this.payStatus = payStatus;
    }
	
	public Integer getStatus() {
    	return status;
    }
	
    public void setStatus(Integer status) {
    	this.status = status;
    }
	
	public Integer getPayType() {
    	return payType;
    }
	
    public void setPayType(Integer payType) {
    	this.payType = payType;
    }
	
	public String getReceiveName() {
    	return receiveName;
    }
	
    public void setReceiveName(String receiveName) {
    	this.receiveName = receiveName;
    }
	
	public String getReceiveMobile() {
    	return receiveMobile;
    }
	
    public void setReceiveMobile(String receiveMobile) {
    	this.receiveMobile = receiveMobile;
    }
	
	public String getZipcode() {
    	return zipcode;
    }
	
    public void setZipcode(String zipcode) {
    	this.zipcode = zipcode;
    }
	
	public Province getProvince() {
    	return province;
    }
	
    public void setProvince(Province province) {
    	this.province = province;
    }
	
	public City getCity() {
    	return city;
    }
	
    public void setCity(City city) {
    	this.city = city;
    }
	
	public District getDistrict() {
    	return district;
    }
	
    public void setDistrict(District district) {
    	this.district = district;
    }
	
	public String getAddress() {
    	return address;
    }
	
    public void setAddress(String address) {
    	this.address = address;
    }
	
	public String getExpressCompany() {
    	return expressCompany;
    }
	
    public void setExpressCompany(String expressCompany) {
    	this.expressCompany = expressCompany;
    }
	
	public String getExpressNo() {
    	return expressNo;
    }
	
    public void setExpressNo(String expressNo) {
    	this.expressNo = expressNo;
    }
	
	public String getOperatorRemark() {
    	return operatorRemark;
    }
	
    public void setOperatorRemark(String operatorRemark) {
    	this.operatorRemark = operatorRemark;
    }
	
	public String getFactoryRemark() {
    	return factoryRemark;
    }
	
    public void setFactoryRemark(String factoryRemark) {
    	this.factoryRemark = factoryRemark;
    }
	
	public Integer getInvoiceType() {
    	return invoiceType;
    }
	
    public void setInvoiceType(Integer invoiceType) {
    	this.invoiceType = invoiceType;
    }
	
	public String getInvoiceTitle() {
    	return invoiceTitle;
    }
	
    public void setInvoiceTitle(String invoiceTitle) {
    	this.invoiceTitle = invoiceTitle;
    }

	public List<OrderItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}
	
}
